package com.mcx.modules;

import com.mcx.modules.domain.Player;
import com.mcx.modules.service.dto.PlayerDto;
import com.mcx.modules.socket.ClientSocket;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@Slf4j
public class PlayerEntity {

    // 当前角色Id
    public int id=0;

    // 角色昵称
    public String nickName;

    public int status;

    // 角色等级
    public int level;

    public int sex;


    // 玩家拥有的
    public int money;

    public int exp;

    public Integer currLineupId;

    public Integer currSelectLineupIndex;

    public Integer lastInWorldMapId;

    public String lastInWorldMapPos;

    public Integer PrevWorldMapId;

    public Integer accountId;

    public Integer gameserverId;

    public ClientSocket Client_Socket;

    public void dtoToEntity(PlayerDto playerDto){
        id = playerDto.getId();
        nickName = playerDto.getNickName();
        status = playerDto.getStatus();
        level = playerDto.getLevel();
        sex = playerDto.getSex();
        money = playerDto.getMoney();
        exp  =playerDto.getExp();
        currLineupId = playerDto.getCurrLineupId();
        currSelectLineupIndex = playerDto.getCurrSelectLineupIndex();
        lastInWorldMapId = playerDto.getLastInWorldMapId();
        lastInWorldMapPos = playerDto.getLastInWorldMapPos();
        accountId = playerDto.getAccountId();
        gameserverId = playerDto.getGameserverId();
    }

    public Player entityToDomain() {
        Player player = new Player();
        player.setId(id);
        player.setNickName(nickName);
        player.setStatus(status);
        player.setLevel(level);
        player.setSex(sex);
        player.setMoney(money);
        player.setExp(exp);
        player.setCurrLineupId(currLineupId);
        player.setCurrSelectLineupIndex(currSelectLineupIndex);
        player.setLastInWorldMapId(lastInWorldMapId);
        player.setLastInWorldMapPos(lastInWorldMapPos);
        player.setAccountId(accountId);
        player.setGameserverId(gameserverId);
        return player;
    }
}
